<!-- 资源管理组件 -->
<template>
	<div id="permismanage">
		<template>
			<el-table :data="zNodes" border style="width: 100%">
				<el-table-column prop="id" label="权限编号" width="180">
				</el-table-column>
				<el-table-column prop="permistitle" label="权限文本" width="180">
				</el-table-column>
				<el-table-column prop="href" label="链接">
				</el-table-column>
				<el-table-column prop="parent" label="所属父菜单">
				</el-table-column>
				<el-table-column prop="permisname" label="权限名字">
				</el-table-column>
				<el-table-column prop="permistype" label="权限类型">
				</el-table-column>
				<el-table-column prop="description" label="描述">
				</el-table-column>
				<el-table-column>
					<template slot="header" slot-scope="scope">
						<el-button icon="el-icon-circle-plus-outline" type="primary" plain size="mini" slot="reference"
							@click="childadd">打开资源添加页面</el-button>
						<addpermismanageVue ref="refpermis"></addpermismanageVue>
					</template>
					<template slot-scope="scope">
						<el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>

						<el-button size="mini" type="danger"
							@click="handleDelete(scope.$index, scope.row)">删除</el-button>
						<updatepermismanageVue ref="refupdate"></updatepermismanageVue>
					</template>
				</el-table-column>
			</el-table>
			<el-pagination :page-size="20" :pager-count="10" style="margin-top: 20px;" background
				layout="prev, pager, next" :total="1000" @current-change="handleCurrentChange">
			</el-pagination>
		</template>
	</div>
</template>

<script>
	import addpermismanageVue from './addpermismanage.vue';
	import updatepermismanageVue from './updatepermismanage.vue';

	export default {
		name: "permismanage",
		data() {
			return {
				zNodes:[{}],
				pageSize: "", //显示每页的条数
				total: "", //总条数
				pager: "" ,//当前页
				//绑定资源表单显示
				dialogFormVisibleAdd: false
			}
		},
		methods: {
			handleEdit(index, row) {

				console.log(index, row);
				this.$refs.refupdate.refupdateper(true, row);

			},
			handleDelete(index, row) {
				console.log(index, row);
				this.$confirm('是否删除数据?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$message({
						type: 'success',
						message: '删除成功!'
					});
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			//资源添加页面
			childadd() {
				this.$refs.refpermis.permis(true);
			},
			handlePageChange(currentPage) {
				this.tablePage.pageNum = currentPage
				// 在此刷新数据
			},
			handleSizeChange(pageSize) {
				this.tablePage.pageSize = pageSize
				// 在此刷新数据
			},
			// 分页查询
			chaxun(page){
				this.axios.get("http://localhost:8080/permis/selectpage1/"+ page, {
				  params: {
				  },
				  headers: {
				    "token": "123"
				  }
				}).then((res) => {
				 this.total = res.data.datamap.chaxun.total; //总页数
				 this.pageSize = res.data.datamap.chaxun.pageSize;
				 this.pager = res.data.datamap.chaxun.pageNum;
				 this.zNodes = res.data.datamap.chaxun.list;
				}).catch(err => {
				  console.log(err)
				});
			},
			handleCurrentChange(val) {
				this.pager=val;
				this.chaxun(val);
			}
		},
		components: {
			addpermismanageVue,
			updatepermismanageVue
		},
		mounted(){
			this.chaxun(1);
		}
	}
</script>

<style>
</style>